<?php
namespace app\shop\model;
use app\BaseModel;
use think\facade\Db;



class IndexShopSpe extends BaseModel
{
    //定义表名
    protected $name = 'longbing_card_shop_spe';

    protected static function init()
    {
        //TODO:初始化内容
    }
    /**
     * @param $dis
     * @param int $page
     * @return mixed
     * 获取商城配置
     */
    public function goodsSpe($dis){
        $data = $this->where($dis)->select()->toArray();
        return $this->getTree($data,0);
    }

    /**
     * @param $data
     * @param $pId
     * @return array
     * 递归无限极
     */
    public function getTree($data, $pId){
        $tree = array();
        if(!empty($data)){
            foreach($data as $k => $v) {
                if($v['pid'] == $pId) {
                    $v['children'] = $this->getTree($data, $v['id']);
                    $tree[]   = $v;
                }
            }
        }
        return $tree;
    }

}